package com.huohuzhihui.web.controller.api;

import com.huohuzhihui.api.service.ApiDouyinUserService;
import com.huohuzhihui.api.service.ApiDyActivityVideoService;
import com.huohuzhihui.common.constant.Constants;
import com.huohuzhihui.common.core.controller.BaseController;
import com.huohuzhihui.common.core.domain.AjaxResult;
import com.huohuzhihui.common.core.domain.entity.SysDept;
import com.huohuzhihui.common.core.domain.entity.SysUser;
import com.huohuzhihui.common.core.domain.model.LoginUser;
import com.huohuzhihui.common.core.page.TableDataInfo;
import com.huohuzhihui.common.utils.DateUtils;
import com.huohuzhihui.common.utils.StringUtils;
import com.huohuzhihui.douyin.basis.response.video.VideoListRes;
import com.huohuzhihui.douyin.basis.response.video.VideoPoiRes;
import com.huohuzhihui.douyin.domain.DouyinUser;
import com.huohuzhihui.douyin.domain.DouyinUserVideo;
import com.huohuzhihui.douyin.service.IDouyinUserService;
import com.huohuzhihui.douyin.service.IDouyinUserVideoService;
import com.huohuzhihui.framework.web.service.TokenService;
import com.huohuzhihui.merchant.domain.MerCoupon;
import com.huohuzhihui.merchant.domain.MerCouponActivity;
import com.huohuzhihui.merchant.domain.MerCouponGet;
import com.huohuzhihui.merchant.domain.MerDouyin;
import com.huohuzhihui.merchant.service.*;
import com.huohuzhihui.system.service.ISysDeptService;
import com.ijpay.core.kit.IpKit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;

/**
 * 微信api
 *
 * @author lizhihe
 * @date 2020-11-22
 */
@RestController
@RequestMapping("/api/order")
public class ApiOrderController extends BaseController {
    @Autowired
    private IOrderService orderService;
    @Autowired
    private TokenService tokenService;


    @PostMapping("/add")
    public AjaxResult add(HttpServletRequest request, int source, String payChannel, Long goodsId, String openId) {
        LoginUser loginUser = tokenService.getLoginUser(request);
        SysUser sysUser = loginUser.getUser();
        String ip = IpKit.getRealIp(request);
        if (StringUtils.isBlank(ip)) {
            ip = "127.0.0.1";
        }
        return new AjaxResult(200, "新增订单成功", orderService.recharge(sysUser, ip, source, payChannel, goodsId, openId));
    }


}
